package com.example.smart.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.smart.pojo.AdminRole;
import com.example.smart.pojo.Menu;
import com.github.yulichang.base.MPJBaseMapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MenuMapper extends BaseMapper< Menu >, MPJBaseMapper < Menu >{
    @Select("SELECT m.* FROM sys_admin_role ar " +
            "INNER JOIN sys_role r ON ar.role_id = r.role_id " +
            "INNER JOIN sys_role_menu rm ON ar.role_id = rm.role_id " +
            "INNER JOIN sys_menu m ON m.menu_id = rm.menu_id " +
            "WHERE admin_id = #{adminId} AND r.role_status = 0 AND m.menu_status = 0")
    List<String> selectPermsByAdminId(Integer adminId);

    /*@Select("SELECT m.menu_id, m.menu_parent_id, m.menu_name, m.menu_path, m.menu_perms, " +
            "m.menu_type, m.menu_icon, m.order_num, m.menu_visible, m.menu_status, " +
            "m.create_time, m.update_time " +
            "FROM sys_menu m " +
            "INNER JOIN sys_role_menu rm ON m.menu_id = rm.menu_id " +
            "WHERE rm.role_id IN " +
            "<foreach collection='roleIds' item='roleId' open='(' separator=',' close=')'>" +
            "#{roleId}" +
            "</foreach>" +
            "AND m.menu_status = 0 AND m.menu_isDelete = 0")
    List<Menu> selectByRoleIds(@Param("roleIds") List<Integer> roleIds);*/
}
